<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/templateList.xhtml">

<ui:define name="body">

	<table align="right">
		<tr>
			<td>
				<h:commandButton immediate="true"
					onclick="abrirPopup('help_online/help_prontuario.seam');" 
					title="Ajuda Online"
					alt="Ajuda Online"
					image="img/help_peq.jpg"/>
			</td>
		</tr>
	</table>
	
	<h2 class="title"><a href="#">Gerenciar Prontuários</a></h2><br/>
	
            <h:form id="prontuarioForm">
            
	           <h:panelGrid columns="1">
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Cliente:</ui:define>
	            		<a:region>
		            		<h:selectOneMenu value="#{manterProntuarioController.idClienteSelecionado}"
		            			style="width:250px"
		            			required="true">
								<f:selectItems value="#{manterProntuarioController.listaClientes}"/>
								<a:support event="onchange" reRender="listaPets" />	            		
		            		</h:selectOneMenu>
	            		</a:region>
	            	</s:decorate>
	            	
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Pet:</ui:define>
	            		<h:selectOneMenu value="#{manterProntuarioController.idPetSelecionado}"
	            			id="listaPets"
	            			style="width:250px"
	            			required="true">
							<f:selectItems value="#{manterProntuarioController.listaPets}"/>	            		
	            		</h:selectOneMenu>
	            	</s:decorate>
	            	
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Funcionário atendente (Veterinário):</ui:define>
	            		<h:selectOneMenu value="#{manterProntuarioController.idFuncionarioSelecionado}"
	            			style="width:250px"
	            			required="false">
							<f:selectItems value="#{manterProntuarioController.listaFuncionarios}"/>	            		
	            		</h:selectOneMenu>
	            	</s:decorate>
	            	
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Data do atendimento:</ui:define>
	            		<rich:calendar value="#{manterProntuarioController.prontuarioEdicao.dtaAtendimento}"
	            			enableManualInput="true"
	            			oninputkeydown="Mascara(this,Data)"
	            			oninputkeyup="Mascara(this,Data)"
	            			datePattern="dd/MM/yyyy"
	            			required="true"
	            			showWeekDaysBar="false"/>
	            	</s:decorate>
	            	
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Retorno?:</ui:define>
	            		<h:selectOneRadio value="#{manterProntuarioController.prontuarioEdicao.flgRetorno}"
	            			required="true">
	            			<f:selectItem itemLabel="SIM" itemValue="T"/>
	            			<f:selectItem itemLabel="NÃO" itemValue="F"/>
	            		</h:selectOneRadio>
	            	</s:decorate>
	            	
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Descrição do atendimento:</ui:define>
	            		<h:inputTextarea value="#{manterProntuarioController.prontuarioEdicao.dscAtendimento}"
	            			required="true"
	            			rows="15"
	            			cols="70">
	            			<f:validateLength maximum="400"/>
	            		</h:inputTextarea>
	            	</s:decorate>
	            	
	            </h:panelGrid>
	            <br/>
	            <div class="actionButtons">
		        	<h:commandButton id="submit" value="Salvar" 
		        		action="#{manterProntuarioController.inicializaPopupPagamento()}"
		        		onclick="#{rich:component('carregando')}.show()"/>
		            	
		            <a:commandButton id="cancel" value="Cancelar" 
		            	onclick="#{rich:component('carregando')}.show()"
		            	oncomplete="#{rich:component('carregando')}.hide()"
		        		action="#{manterProntuarioController.cancelar}" 
		        		ajaxSingle="true"
		        		reRender="prontuarioForm"/>
		        </div>
				<br/>
				
			</h:form>
			
		<rich:modalPanel id="modalPagamento" height="230" width="350"
			showWhenRendered="#{manterProntuarioController.exibePopupPagamento}">
           	<f:facet name="header">
	            <h:panelGroup>
	                <h:outputText value="Pagamento"></h:outputText>
	            </h:panelGroup>
	        </f:facet>
	        <f:facet name="controls">
	            <h:panelGroup>
	            	<h:form>
		                <h:commandButton image="/img/close.png" id="hidelinkServ"
		                	onclick="#{rich:component('carregando')}.show()"
		                	action="#{manterProntuarioController.fecharPopupPagamento()}"/>
                	</h:form>
	            </h:panelGroup>
	        </f:facet>

			<h:form id="pagamentoForm">
				<h:panelGrid columns="1">
					<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Valor do serviço:</ui:define>
	            		<h:inputText value="#{manterProntuarioController.prontuarioEdicao.vlrAtendimento}"
	            			onkeydown="Mascara(this,Valor)"
		            		onkeyup="Mascara(this,Valor)"
			            	converter="conversorMonetario"
			            	required="true"/>
	            	</s:decorate>
	            	
					<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Pago?</ui:define>
	            		<h:selectOneRadio value="#{manterProntuarioController.prontuarioEdicao.flgPago}"
	            			required="true">
	            			<f:selectItem itemValue="T" itemLabel="SIM"/>
	            			<f:selectItem itemValue="T" itemLabel="NÃO"/>
	            		</h:selectOneRadio>
	            	</s:decorate>
	            	
					<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Forma Pagamento</ui:define>
	            		<h:selectOneMenu value="#{manterProntuarioController.idFormaPagamento}"
	            			style="width: 150px;"
	            			required="true">
	            			<f:selectItems value="#{manterProntuarioController.listaFormasPagamento}"/>
	            		</h:selectOneMenu>
	            	</s:decorate>
				</h:panelGrid>
				<div class="actionButtons">
		        	<h:commandButton id="submitPopup" value="Confirmar" action="#{manterProntuarioController.salvar()}"
		            	onclick="javascript:if(!confirm('Tem certeza que deseja salvar?'))return false;#{rich:component('carregando')}.show()"/>
		            <h:commandButton id="cancelPopup" value="Cancelar" 
		            	onclick="#{rich:component('carregando')}.show()"
		        		action="#{manterProntuarioController.fecharPopupPagamento()}" 
		        		immediate="true"/>
		        </div>
			</h:form>
		</rich:modalPanel>
			
 </ui:define>
</ui:composition>
